package top.zlcode.friend.controller.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.zlcode.common.core.controller.BaseController;
import top.zlcode.common.core.domain.R;
import top.zlcode.common.core.domain.TableDataInfo;
import top.zlcode.friend.aspect.CheckUserStatus;
import top.zlcode.friend.domain.exam.dto.ExamDTO;
import top.zlcode.friend.domain.exam.dto.ExamQueryDTO;
import top.zlcode.friend.service.user.IUserExamService;

/**
 * 用户报名竞赛控制层
 */
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {

    @Autowired
    private IUserExamService userExamService;

    /**
     * 报名竞赛
     * @param examDTO
     * @return
     */
    @CheckUserStatus
    @PostMapping("/enter")
    public R<Void> enter(@RequestBody ExamDTO examDTO) {
        return toR(userExamService.enter(examDTO));
    }

    /**
     * 当前用户报名的竞赛
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return userExamService.getList(examQueryDTO);
    }
}
